package com.zzj.web.controller.dusto.shop;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zzj.common.annotation.Log;
import com.zzj.common.core.controller.BaseController;
import com.zzj.common.core.domain.AjaxResult;
import com.zzj.common.enums.BusinessType;
import com.zzj.bill.domain.BillShop;
import com.zzj.bill.service.IShopService;
import com.zzj.common.utils.poi.ExcelUtil;
import com.zzj.common.core.page.TableDataInfo;

/**
 * shopController
 *
 * @author ruoyi
 * @date 2022-01-26
 */
@RestController
@RequestMapping("/bill/shop")
public class ShopController extends BaseController
{
    @Autowired
    private IShopService shopService;

    /**
     * 查询shop列表
     */
    @PreAuthorize("@ss.hasPermi('bill:shop:list')")
    @GetMapping("/list")
    public TableDataInfo list(BillShop billShop)
    {
        startPage();
        List<BillShop> list = shopService.selectShopList(billShop);
        return getDataTable(list);
    }

    /**
     * 导出shop列表
     */
    @PreAuthorize("@ss.hasPermi('bill:shop:export')")
    @Log(title = "shop", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BillShop billShop)
    {
        List<BillShop> list = shopService.selectShopList(billShop);
        ExcelUtil<BillShop> util = new ExcelUtil<BillShop>(BillShop.class);
        util.exportExcel(response, list, "shop数据");
    }

    /**
     * 获取shop详细信息
     */
    @PreAuthorize("@ss.hasPermi('bill:shop:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(shopService.selectShopById(id));
    }

    /**
     * 新增shop
     */
    @PreAuthorize("@ss.hasPermi('bill:shop:add')")
    @Log(title = "shop", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BillShop billShop)
    {
        return toAjax(shopService.insertShop(billShop));
    }

    /**
     * 修改shop
     */
    @PreAuthorize("@ss.hasPermi('bill:shop:edit')")
    @Log(title = "shop", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BillShop billShop)
    {
        return toAjax(shopService.updateShop(billShop));
    }

    /**
     * 删除shop
     */
    @PreAuthorize("@ss.hasPermi('bill:shop:remove')")
    @Log(title = "shop", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(shopService.deleteShopByIds(ids));
    }
}
